#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <sstream>
using namespace std;


int stringToInt(string s) {
	stringstream in(s);
	int x;
	in >> x;
	return x;
}

int main(int argc, char* argv[]) {
	int n = stringToInt(argv[1]);

	fprintf(stderr, "compiling...\n");
	system("g++ src.cpp -o src.exe -O2\n");

	double totalScore = 0;
	double totalScoreAfter3 = 0;

	for (int i = 1; i <= n; ++i) {
		char str[1000];
		sprintf(str, "\"C:\\Program Files (x86)\\Java\\jre6\\bin\\java.exe\" -jar Tester.jar -exec src.exe -dump res.dmp -seed %d >out", i);
		fprintf(stderr, "%s\n", str);
		system(str);
		ifstream fout("out");
		while (true) {
			string w;
			fout >> w;
			double score;
			if (w == "Score") {
				fout >> w;
				fout >> score;
				printf("#%d: %.1lf\n", i, score);
				totalScore += score;
				if (i > 3) {
					totalScoreAfter3 += score;
				}
				break;
			}
		}
		fout.close();
	}
	printf("\nTotal: %.1lf\n", totalScore);
	if (totalScoreAfter3 > 0) {
		totalScoreAfter3 /= (n - 3);
	}
	printf("\nAverage: %.1lf\n", totalScoreAfter3);
	return 0;
}